<?php

namespace App\Admin\Actions\Grid;


use App\Admin\Forms\CustomerBatchAllotForm;
use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Widgets\Modal;

class CustomerBatchAllot extends BatchAction
{
    /**
     * @return string
     */
	protected $title = '批量分配';

    public function render()
    {
        // 实例化表单类并传递自定义参数
        $form = CustomerBatchAllotForm::make();
        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            ->onLoad($this->getModalScript())
            ->button($this->title);
    }

    protected function getModalScript()
    {
        // 弹窗加载后往ids隐藏域写入批量选中的行ID
        return <<<JS
        // 获取选中的ID数组
        var key = {$this->getSelectedKeysScript()}
        $('#ids').val(key);
JS;
    }


}
